home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-06 | 3.2 KB | 147 lines | [TEXT/MPS ] |
- // Copyright © 1991 Apple Computer, Inc. All rights reserved.
- // Example of a modal dialog with a PICT inside, with some additional
- // TEditText control.
- // Kent Sandvik DTS
-
- #ifndef __UDIALOGS__
- #include "UDialogs.h"
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __PACKAGES__
- #include <Packages.h>
- #endif
-
- #ifndef __UMEMORY__
- #include <UMemory.h>
- #endif
-
- #ifndef __USCROLLER__
- #include <UScroller.h>
- #endif
-
- #ifndef __UVIEWSERVER__
- #include <UViewServer.h>
- #endif
-
- #ifndef __UDRAWINGENVIRONMENT__
- #include <UDrawingEnvironment.h>
- #endif
-
- #ifndef __UFAILURE__
- #include <UFailure.h>
- #endif
-
- #ifndef __UGEOMETRY__
- #include <UGeometry.h>
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __UMENUMGR__
- #include <UMenuMgr.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __UWINDOW__
- #include <UWindow.h>
- #endif
-
- #ifndef __UCONTROL__
- #include <UControl.h>
- #endif
-
- #define kSignature 'MOOF' // qpplication signature
- #define kFileType 'SF01' // file type code used for document files created by this application
-
- const short kModalID = 3000;
- const short cName = 4000;
-
- //============================================================================
- #undef Inherited
- #define Inherited TApplication
-
- #pragma segment AInit
- DefineClass(TDialogsApplication, TApplication);
-
- void TDialogsApplication::IDialogsApplication()
- {
- this->IApplication(kFileType, kSignature);
-
- fLaunchWithNewDocument = false; // Suppress the creation of a new document at launch
-
- }
-
-
- //------------------------------------------------------------------------------
- #pragma segment ASelCommand
- void TDialogsApplication::DoMenuCommand(CommandNumber aCommandNumber) // override
-
- {
- switch (aCommandNumber){
-
- case cName:
- this->ShowModalDialog(); // show dialog box
- break;
-
- default: // always do this, so other objects get a chance
- Inherited::DoMenuCommand(aCommandNumber);
-
- }
- }
-
-
- //------------------------------------------------------------------------------
- #pragma segment ARes
- void TDialogsApplication::DoSetupMenus()
- {
- Inherited::DoSetupMenus(); // always do this, so other objects get chance
- Enable(cName, true);
- }
-
-
- //------------------------------------------------------------------------------
- #pragma segment ASelCommand
- void TDialogsApplication::ShowModalDialog()
- {
- const IDType kDialogView = 'dlog'; // dialog view identifier
- const IDType kName = 'name'; // edit text identifier
- const IDType kOK = 'okok'; // OK button identifier
- const IDType kCancel = 'cncl'; // Cancel button identifier
- const IDType kPict = 'pic1'; // PICT view
-
- TWindow *aWindow;
-
- FailNIL(aWindow = gViewServer->NewTemplateWindow(kModalID, NULL));
-
- TDialogView *aDialogView = (TDialogView *) aWindow->FindSubView(kDialogView);
- TEditText *anEditText = (TEditText *) aWindow->FindSubView(kName);
- TPicture *aPicture = (TPicture *) aWindow->FindSubView(kPict);
-
- IDType dismisser = aWindow->PoseModally(); // show the modal dialog
-
- aWindow->Close(); // dispose of the dialog window
- }
-
-
-